package cn.pegasus.teamwork.pegasus.service.impl;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.pegasus.teamwork.pegasus.entity.BussUserOpinion;
import cn.pegasus.teamwork.pegasus.mapper.BussUserOpinionMapper;
import cn.pegasus.teamwork.pegasus.service.BussUserOpinionService;
import cn.iyizhan.teamwork.base.service.impl.BaseServiceImpl;
import cn.iyizhan.teamwork.base.util.PageHelper;
import cn.iyizhan.teamwork.base.util.PageObject;

/**
 * @author ryan.bian
 * @version 
 */
@Service("opinionService")
public class BussUserOpinionServiceImpl extends BaseServiceImpl<BussUserOpinion, BussUserOpinionMapper> implements BussUserOpinionService {
	// 注入当前dao对象
    @Autowired
    private BussUserOpinionMapper bussUserOpinionMapper;

    public BussUserOpinionServiceImpl() {
        setMapperClass(BussUserOpinionMapper.class, BussUserOpinion.class);
    }

	@Override
	public PageObject<BussUserOpinion> PageList(Map<String, Object> map) {
        int totalData = bussUserOpinionMapper.getTotal(map);
        PageHelper pageHelper = new PageHelper(totalData, map);
        List<BussUserOpinion> list = bussUserOpinionMapper.findListPage(pageHelper.getMap());
        if(null != list && list.size() > 0){
        	for(BussUserOpinion o : list){
        		if(null != o.getImages() && !o.getImages().equals("")){
        			String[] str = o.getImages().split(",");
        			List<String> imageList = Arrays.asList(str);
        			o.setImageList(imageList);
        		}
        	}
        }
        PageObject<BussUserOpinion> pageObject = pageHelper.getPageObject();
        pageObject.setDataList(list);
		return pageObject;
	}
    
 
}
